<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link th:href="@{/erp/Widget/icheck/icheck.css}" rel="stylesheet" type="text/css"/>
    <!--[if IE 7]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome-ie7.min.css}"/>
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <![endif]-->
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <!--    <script type="text/javascript" th:src="@{/erp/js/H-ui.js}"></script>
        <script type="text/javascript" th:src="@{/erp/js/H-ui.admin.js}"></script>-->
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
    <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>
    <title>待生产订单查询</title>

</head>


<body>

<div class="margin clearfix">
    <div class="stystems_style">
        <div class="tabbable">
            <div class="page-content clearfix">
                <div id="Member_Ratings">
                    <!--<div class="d_Confirm_Order_style">
                  <ul class="nav nav-tabs" id="myTab">
                    <li class="active">
                      <a data-toggle="tab" href="#home"><i class="green fa fa-home bigger-110"></i>待生产订单查询</a></li>
                  </ul>
                  </div>-->
                    <div class="tab-content">

                        <div id="home" class="tab-pane active">

                            <div class="search_style">
                                <!--根据待生产订单编号查询-->
                                <form>
                                    <ul class="search_content clearfix">
                                        <li><label class="l_f">查询待生产订单：</label><input onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"
                                                                                      name="orderId" type="text" class="text_add"
                                                                                      placeholder="输入12位数的订单编号"
                                                                                      style=" width:400px"/></li>
                                        <li style="width:90px;">
                                            <button type="button" class="btn_search" id="sel"><i class="icon-search"></i>查询</button>
                                        </li>
                                    </ul>
                                </form>
                            </div>
                            <table class="table table-striped table-bordered table-hover" id="sample-table">
                                <thead>
                                <tr>
                                    <th hidden="hidden">序号</th>
                                    <th width="80">序号</th>
                                    <th width="150">订单编号</th>
                                    <th width="150">产品名称</th>
                                    <th width="150">生产数量</th>
                                    <th width="150">生产产线</th>
                                    <th width="100">使用打印机</th>
                                    <th width="150">计划生产时间</th>
                                    <th width="150">备注</th>
                                    <th width="150">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!--编辑产线图层-->
                    <div class="add_menber" id="add_menber_styl" style="display:none">

                        <ul class=" page-content">
                            <div class="prompt r_f"></div>
                            <li><label class="label_name">生产产线：</label>
                                <span class="add_name">
                                <select name="productionLineName" id="productionLineName" style=" width:200px">
                                </select>
                                </span>
                                <div class="prompt r_f"></div>
                            </li>

                            <li style="position: relative;left: -15px;"><label class="label_name" style="width: 105px;">使用打印机：</label>
                                <span class="add_name">
                                <select name="printerName" id="printerName" style="width:200px"></select>

                                </span>
                            </li>
                            <li><label class="l_f">生产时间</label>
                                <input class="inline laydate-icon" id="sqcsj" name="sqcsj" style=" margin-left:10px;"></li>
                            <div class="prompt r_f"></div>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" th:inline="none">
    //消息提醒
    var remind;

    $(function () {
        var table = $('#sample-table').dataTable({
            "autoWidth": false,
            searching : false,
            serverSide : true,
            aoColumnDefs: [
                {"orderable": false, "aTargets": [1, 2, 3, 4, 5, 6]}// 制定列不参与排序
            ],
            ajax: {
                url: '/pendingOrder/page',
                type: 'get',
                data: function (d) {
                    var data = $('form').serialize();   //获取查询条件

                    //获取分页信息
                    var searchParams = {
                        start: d.start,
                        length: d.length,
                    };
                    data = data + '&' + $.param(searchParams);
                    return data;
                }
            },
            columns: [
                {"data": "id", "className" : "hidden"},
                {"data": "order_id","createdCell": function (td,cellData,rowData,row,col) {
                        $(td).empty().append(row+1);
                    } },
                {"data": "order_id", 'sDefaultContent': ''},
                {"data": "p_name", 'sDefaultContent': ''},
                {"data": "number", 'sDefaultContent': ''},
                {"data": "production_name", 'sDefaultContent': ''},
                {"data": "printer", 'sDefaultContent': ''},
                {"data": "productPlanTime", 'sDefaultContent': ''},
                {"data": "remark", 'sDefaultContent': ''},
                {
                    "data": "id", "createdCell": function (td, cellData, rowData, row, col) {
                        $(td).empty().append('<a title="添加到激光码管理列表" onclick="member_edit(this)" class="btn btn-xs btn-info " id="update" href="javascript:;" ><i class="fa" >添加到激光码管理列表</i></a>');
                    }
                },
            ]
        });

        //搜索按钮事件
        $('#sel').click(function () {
            table.fnUpdate();
        })
    })

    /*加入到激光码生成页面*/
    function member_edit(e) {
        var orderId= $(e).parent().parent().children("td:eq(2)").text();
        document.getElementById('productionLineName').value = $(e).parent().parent().children("td:eq(5)").text();
        document.getElementById('printerName').value = $(e).parent().parent().children("td:eq(6)").text();
        layer.open({
            type: 1,
            title: '设置生产记录',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area: ['800px', ''],
            content: $('#add_menber_styl'),
            btn: ['确认加入', '取消'],
            yes: function (index, layero) {
                var num = 0;
                var str = "";
                $(".add_menber input[type$='text']").each(function (n) {
                    if ($(this).val() == "") {
                        layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                            title: '提示框',
                            icon: 0,
                        });
                        num++;
                        return false;
                    }
                });
                if (num > 0) {
                    return false;
                } else {
                    var data =
                        console.log(JSON.stringify(data));
                    $.ajax({
                        type:'post',
                        dataType:'json',
                        contentType:'application/json',
                        url:'/pendingOrder/updatePendingOrder',
                        data :JSON.stringify({
                            'orderId' : orderId,
                            'productLineId' : $("#productionLineName").val(),
                            'printer' : $("#printerName").val(),
                            'productTime' : $("#sqcsj").val(),
                        }),
                        success: function(d){
                            parent.document.getElementById('iframe').contentWindow.location.reload(true);
                        },
                    })
                    layer.open({
                        title: '提示',
                        content: '加入成功！是否跳转至该页面？'
                        , btn: ['确定', '取消'],
                        yes: function () {
                            window.location.href = '/laser/jgm';
                        }
                    });
                    layer.close(index);
                }
            }
        });
    }
    /*编辑*/
    //编辑层里面的生产线选择1
    $(function () {
        $.ajax({
            url: "/pendingOrder/findProductionLineName",
            type: "get",
            async: false,//同步或异步
            dataType: "json",
            success: function (data) {
                showName1(data);
            },
            error: function () {
                alert("请求超时，稍后再试！")
            }
        });
    })

    function showName1(data) {
        for (var i = 0; i < data.length; i++) {
            var value = data[i];
            var lable = value;
            $('#productionLineName').append("<option value=" + value + ">" + lable + "</option>");
        }
    }
    /***************************************************************************************************************************************/
    //编辑层里面的打印机选择2
    $(function () {
        $.ajax({
            url: "/pendingOrder/findAllPrinterName",
            type: "get",
            async: false,//同步或异步
            dataType: "json",
            success: function (data) {
                showName2(data);
            },
            error: function () {
                alert("请求超时，稍后再试！")
            }
        });
    })

    function showName2(data) {
        for (var i = 0; i < data.length; i++) {
            var value = data[i];
            var lable = value;
            $('#printerName').append(
                "<option value=" + value + ">" + lable + "</option>");
        }
        return;
    }
    laydate.render({
        elem: '#sqcsj',
        type: 'datetime',
        min: getNowFormatDate()
    });
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    }
</script>

</body>
</html>
